package com.example.tests;

import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;

import org.testng.annotations.Test;

import com.example.fw.Folders;

public class TestFolderCreation extends TestBase {

	 @Test
	 public void testFolderCreation(){
	  String folder1 = "newfolder6000";
	  String folder2 = "newfolder7000";
	  Folders oldFolders = app.getFolderHelper().getFolders();
	  assertThat(app.getFolderHelper().createFolder(folder1), is (nullValue()));
	  Folders newFolders = app.getFolderHelper().getFolders();
	  oldFolders.addFolder(folder1);
	  assertEquals(newFolders, oldFolders);
	  oldFolders.addFolder(folder2);
	  assertEquals(newFolders, oldFolders);
	  Folders newFolders2 = app.getFolderHelper().getFolders();
	  newFolders.addFolder(folder2);
	  assertEquals(newFolders2, newFolders);
	 }
	 
		

	@Test
	 public void testFolderWithSameName(){
	   String folder = "newfolder10000";
	   Folders oldFolders = app.getFolderHelper().getFolders();
	   assertThat(app.getFolderHelper().createFolder(folder),is (nullValue()));
	   Folders newFolders = app.getFolderHelper().getFolders();
	   oldFolders.addFolder(folder);
	   assertEquals(newFolders, oldFolders);
	   assertThat(app.getFolderHelper().createFolder(folder), containsString("Duplicatod folder name"));
	   Folders newFolders2 = app.getFolderHelper().getFolders();
	   newFolders.addFolder(folder);
	   assertEquals(newFolders, newFolders2);
	 }
	 
	}
